#ifndef FENETRE_H
#define FENETRE_H

#include <QWidget>
#include <QApplication>
#include <QMessageBox>
#include <list>
#include <sstream>
#include "QSFMLCanvas.hpp"
#include "defaultscreen.h"
#include "salonscreen.h"
#include "MyCanvas.h"
#include "mythread.h"
#include "client.h"
#include "Etat.h"

namespace Ui {
    class Fenetre;
}

typedef struct
{
    std::string nom;
} MyClient;

typedef struct
{
    std::string nom;
    sf::Uint8 nbJoueursAct;
    sf::Uint8 nbJoueursMax;
} MyGame;

enum eScreen
{
    eDEF = 1,
    eCFG = 2,
    eSAL = 3,
    eCANV = 4
};

class ConfigGame;

class Fenetre : public QWidget
{
    Q_OBJECT
    
public:
    explicit Fenetre(Client* c, MyThread* mt, QWidget *parent = 0);
    ~Fenetre();

    void addText(QString q);
    void addClient(QString q);
    void addPartie(QString q);
    void refreshClients();
    void refreshGames();

    void deleteScreenAct();

public slots:
    // slots main
    void quitter();
    void lineChatReturn();
    void newClient();
    void newGame();
    void newMsg();
    void decoClient();
    void decoGame();
    void createGame();
    void joinGame();
    void sendNewGame();
    void traitementCreateGame();
    void slotAddPartie();
    void slotRmPartie();

    // slots partie
    void slotReady();
    void slotLaunch();
    
private:
    Ui::Fenetre *ui;
    DefaultScreen* defScreen;
    ConfigGame* cfgGame;
    salonScreen* salScreen;
    MyCanvas* canvasSfml;

    MyThread* _mythread;

    Client* _client;

    std::list<MyClient> clients;
    std::list<MyGame> games;

    eScreen scrAct;
};

#endif // FENETRE_H
